<?php
require_once 'application/controllers/AdminController.php';

class LoginController extends CI_Controller{
    
    public function index() {
        $this->load->view('view_login');
    }
    
    public function validateLoginForm(){
        $this->load->model('UserModel');
        $userDNI = $this->input->post('dni');
        $password = $this->input->post('password');
        $isValidUser = $this->UserModel->validateUser($userDNI, $password);
        if($isValidUser){
            $mainController = new AdminController();
            $mainController->index();
        }else{
            $data['loginMessage'] = "DNI o contraseña incorrecta";
            $this->load->view('view_login', $data);
        }
    }
    
    
}

?>
